{% extends "admin/index.html" %}
{% from "macros.html" import render_pagination %}

{% block title %}
Admin - courses
{% endblock %}

{% block operation %}
<a href="{{ url_for('admin.create_course') }}" type="button" class="btn btn-primary">
  <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
  添加课程
</a>
{% endblock %}

{% block admin %}
<table class="table">
  <thead>
    <tr>
      <th>ID</th>
      <th>名称</th>
      <th>作者</th>
      <th>操作</th>
    </tr>
    <tbody>
      {% for course in pagination.items %}
      <tr>
        <td>{{ course.id }}</td>
        <td>{{ course.name }}</td>
        <td>{{ course.author.username }}</td>
        <td>
          <div class="btn-group" role="group">
              <a href="{{ url_for('admin.edit_course', course_id=course.id) }}" type="button" class="btn btn-default">
              <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
            </a>
            <a href="" type="button" class="btn btn-default" onclick="confirm('确定要删除该课程吗？')">
              <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
            </a>
          </div>
        </td>
      </tr>
      {% endfor %}
    </tbody>
  </thead>
</table>
{{ render_pagination(pagination, 'admin.courses') }}
{% endblock %}
